package xyz.zdsoft.ask_for_leave_manage_module.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.ask_for_leave_manage_module.bo.TeacherSearchBo;
import xyz.zdsoft.ask_for_leave_manage_module.service.TeacherLeaveService;
import xyz.zdsoft.ask_for_leave_manage_module.vo.StudentLeaveForTeacherVo;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.common.utils.ResultBody;

/**
 * @author 夏兵
 */
@RestController
@Api(tags = "教师请假模块")
@RequestMapping("/api/teacher")
public class TeacherLeavesController {

    @Autowired
    private TeacherLeaveService teacherLeaveService;

    @ApiOperation("教师查询请假通过/不通过")
    @GetMapping("/queryStuLeaveForTea")
    public Result<StudentLeaveForTeacherVo> queryStuLeaveForTea(TeacherSearchBo teacherSearchBo) {
        return teacherLeaveService.queryStuLeaveForTea(teacherSearchBo);
    }

    @GetMapping("/passLeave")
    @ApiOperation("通过本条请假")
    @ApiImplicitParam(name = "leaveId", value = "请假id", required = true)
    public ResultBody passLeave(Integer leaveId) {
        return teacherLeaveService.passLeave(leaveId);
    }

    @GetMapping("/eliminateLeave")
    @ApiOperation("淘汰本条请假")
    @ApiImplicitParams({@ApiImplicitParam(name = "leaveId", value = "请假id", required = true),
                        @ApiImplicitParam(name = "reason", value = "请假不通过原因", required = true)})
    public ResultBody eliminateLeave(Integer leaveId, String reason) {
        return teacherLeaveService.eliminateLeave(leaveId, reason);
    }
}
